﻿// Copyright (c) 2010
// by http://openlightgroup.net/

using System;
using System.Net;
using System.ServiceModel;
using SilverlightDebateViewModel.SilverlightDebateWS;

namespace SilverlightDebateViewModel
{
    public class DebateModel
    {
        #region GetXaps
        public static void GetXaps(
            RIAAuthenticationHeader RIAAH,
            String BaseAddress,
            EventHandler<GetXapsCompletedEventArgs> eh)
        {
            // Set up web service call
            WebServiceSoapClient WS = new WebServiceSoapClient();

            // Set the EndpointAddress
            WS.Endpoint.Address = new EndpointAddress(BaseAddress);

            WS.GetXapsCompleted += eh;
            WS.GetXapsAsync(RIAAH);
        }
        #endregion

        #region GetCategories
        public static void GetCategories(
            RIAAuthenticationHeader RIAAH,
            String BaseAddress,
            EventHandler<GetCategoriesCompletedEventArgs> eh)
        {
            // Set up web service call
            WebServiceSoapClient WS = new WebServiceSoapClient();

            // Set the EndpointAddress
            WS.Endpoint.Address = new EndpointAddress(BaseAddress);

            WS.GetCategoriesCompleted += eh;
            WS.GetCategoriesAsync(RIAAH);
        }
        #endregion


        #region GetStatement
        public static void GetStatement(
            int StatementID,
            RIAAuthenticationHeader RIAAH,
            String BaseAddress,
            EventHandler<GetStatementCompletedEventArgs> eh)
        {
            // Set up web service call
            WebServiceSoapClient WS = new WebServiceSoapClient();

            // Set the EndpointAddress
            WS.Endpoint.Address = new EndpointAddress(BaseAddress);

            WS.GetStatementCompleted += eh;
            WS.GetStatementAsync(StatementID, RIAAH);
        }
        #endregion

        #region GetPageOfStatements
        public static void GetPageOfStatements(
            int CategoryID,
            DateTime? StartDate,
            DateTime? EndDate,
            string SearchText,
            int PageSize,
            int PageOffset,
            RIAAuthenticationHeader RIAAH,
            String BaseAddress,
            EventHandler<GetPageOfStatementsCompletedEventArgs> eh)
        {
            // Set up web service call
            WebServiceSoapClient WS = new WebServiceSoapClient();

            // Set the EndpointAddress
            WS.Endpoint.Address = new EndpointAddress(BaseAddress);

            WS.GetPageOfStatementsCompleted += eh;
            WS.GetPageOfStatementsAsync(CategoryID, StartDate, EndDate, SearchText, PageSize, PageOffset, RIAAH);
        }
        #endregion

        #region GetPageOfStatementsWithEmptyContent
        public static void GetPageOfStatementsWithEmptyContent(
            int CategoryID,
            DateTime? StartDate,
            DateTime? EndDate,
            string SearchText,
            int PageSize,
            int PageOffset,
            RIAAuthenticationHeader RIAAH,
            String BaseAddress,
            EventHandler<GetPageOfStatementsWithEmptyContentCompletedEventArgs> eh)
        {
            // Set up web service call
            WebServiceSoapClient WS = new WebServiceSoapClient();

            // Set the EndpointAddress
            WS.Endpoint.Address = new EndpointAddress(BaseAddress);

            WS.GetPageOfStatementsWithEmptyContentCompleted += eh;
            WS.GetPageOfStatementsWithEmptyContentAsync(CategoryID, StartDate, EndDate, SearchText, PageSize, PageOffset, RIAAH);
        }
        #endregion

        #region GetSearchPageOfStatementsWithEmptyContent
        public static void GetSearchPageOfStatementsWithEmptyContent(
            int CategoryID,
            DateTime? StartDate,
            DateTime? EndDate,
            string SearchText,
            int PageSize,
            int PageOffset,
            RIAAuthenticationHeader RIAAH,
            String BaseAddress,
            EventHandler<GetSearchPageOfStatementsWithEmptyContentCompletedEventArgs> eh)
        {
            // Set up web service call
            WebServiceSoapClient WS = new WebServiceSoapClient();

            // Set the EndpointAddress
            WS.Endpoint.Address = new EndpointAddress(BaseAddress);

            WS.GetSearchPageOfStatementsWithEmptyContentCompleted += eh;
            WS.GetSearchPageOfStatementsWithEmptyContentAsync(CategoryID, StartDate, EndDate, SearchText, PageSize, PageOffset, RIAAH);
        }
        #endregion

        #region CreateNewStatement

        public static void CreateNewStatement(
            int categoryID,
            string title,
            string content,
            RIAAuthenticationHeader RIAAH,
            String BaseAddress,
            EventHandler<CreateNewStatementCompletedEventArgs> eh)
        {
            // Set up web service call
            WebServiceSoapClient WS = new WebServiceSoapClient();

            // Set the EndpointAddress
            WS.Endpoint.Address = new EndpointAddress(BaseAddress);

            WS.CreateNewStatementCompleted += eh;
            WS.CreateNewStatementAsync(categoryID, title, content, RIAAH);
        }


        #endregion

        #region GetSupportCountStatement
        public static void GetSupportCountStatement(
            Statement statement,
            bool agree,
            RIAAuthenticationHeader RIAAH,
            String BaseAddress,
            EventHandler<GetSupportCountSatementCompletedEventArgs> eh)
        {
            // Set up web service call
            WebServiceSoapClient WS = new WebServiceSoapClient();

            // Set the EndpointAddress
            WS.Endpoint.Address = new EndpointAddress(BaseAddress);

            WS.GetSupportCountSatementCompleted += eh;
            WS.GetSupportCountSatementAsync(statement, agree, RIAAH);
        }
        #endregion

        #region GetOpinions
        public static void GetOpinions(
            int statementID,
            bool agree,
            RIAAuthenticationHeader RIAAH,
            String BaseAddress,
            EventHandler<GetOpinionsCompletedEventArgs> eh)
        {
            // Set up web service call
            WebServiceSoapClient WS = new WebServiceSoapClient();

            // Set the EndpointAddress
            WS.Endpoint.Address = new EndpointAddress(BaseAddress);

            WS.GetOpinionsCompleted += eh;
            WS.GetOpinionsAsync(statementID, agree, RIAAH);
        }

        #endregion

        #region CanVote
        public static void CanVote(
            int statementID,
            RIAAuthenticationHeader RIAAH,
             String BaseAddress,
            EventHandler<CanVoteCompletedEventArgs> eh)
        {
            // Set up web service call
            WebServiceSoapClient WS = new WebServiceSoapClient();

            // Set the EndpointAddress
            WS.Endpoint.Address = new EndpointAddress(BaseAddress);

            WS.CanVoteCompleted += eh;
            WS.CanVoteAsync(statementID, RIAAH);
        }
        #endregion

        #region ResetVote
        public static void ResetVote(
            int statementID,
            RIAAuthenticationHeader RIAAH,
             String BaseAddress,
            EventHandler<ResetVoteCompletedEventArgs> eh)
        {
            // Set up web service call
            WebServiceSoapClient WS = new WebServiceSoapClient();

            // Set the EndpointAddress
            WS.Endpoint.Address = new EndpointAddress(BaseAddress);

            WS.ResetVoteCompleted += eh;
            WS.ResetVoteAsync(statementID, RIAAH);
        }
        #endregion

        #region SupportOpinion
        public static void SupportOpinion(
            int statementID,
            int opinionID,
            RIAAuthenticationHeader RIAAH,
            String BaseAddress,
            EventHandler<SupportOpinionCompletedEventArgs> eh)
        {
            // Set up web service call
            WebServiceSoapClient WS = new WebServiceSoapClient();

            // Set the EndpointAddress
            WS.Endpoint.Address = new EndpointAddress(BaseAddress);

            WS.SupportOpinionCompleted += eh;
            WS.SupportOpinionAsync(statementID, opinionID, RIAAH);
        }

        #endregion

        #region CreateNewOpinion

        public static void CreateNewOpinion(
            int statementID,
            bool agree,
            String title,
            RIAAuthenticationHeader RIAAH,
            String BaseAddress,
            EventHandler<CreateNewOpinionCompletedEventArgs> eh)
        {
            // Set up web service call
            WebServiceSoapClient WS = new WebServiceSoapClient();

            // Set the EndpointAddress
            WS.Endpoint.Address = new EndpointAddress(BaseAddress);

            WS.CreateNewOpinionCompleted += eh;
            WS.CreateNewOpinionAsync(statementID, RIAAH, agree, title);
        }

        #endregion

    }
}
